//package com.dsj.gxrd.dead;
//
//import com.dsj.gxrd.config.RabbitMqConfig;
//import com.rabbitmq.client.Channel;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.amqp.core.Message;
//import org.springframework.amqp.rabbit.annotation.*;
//import org.springframework.amqp.support.AmqpHeaders;
//import org.springframework.messaging.handler.annotation.Header;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.util.Date;
//
///**
// * @author songpin566
// * @date 2023/11/08
// **/
//@Component
//@Slf4j
//public class DeadMqConsumer {
///*
//    @RabbitListener(queues = RabbitMqConfig.QUEUE_NAME,ackMode = "MANUAL")
//    public void consumer01(Message message, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag, Channel channel) throws IOException {
//        String msg = new String(message.getBody());
//        if(msg.equals("info5")){
//            System.out.println("deadConsumer01 接收到消息:" + message + "并拒绝签收该消息");
//            channel.basicNack(deliveryTag,false,false);
//        }else {
//            System.out.println("deadConsumer01 接收到消息"+message);
//            channel.basicAck(deliveryTag,false);
//        }
//    }*/
//
//    @RabbitListener(bindings ={
//            @QueueBinding(value = @Queue(arguments=
//                    {@Argument(name="x-dead-letter-exchange",value=RabbitMqConfig.DEAD_EXCHANGE),
//                    @Argument(name="x-dead-letter-routing-key",value="lisi")},
//                    value = RabbitMqConfig.QUEUE_NAME,durable = "true"),
//                    exchange =@Exchange(value = RabbitMqConfig.EXCHANGE_NAME),
//                    key = RabbitMqConfig.ROUTING_KEY)},ackMode = "MANUAL")
//    public void consumer01(Message message, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag, Channel channel) throws IOException {
//        String msg = new String(message.getBody());
//        if(msg.equals("info5")){
//            System.out.println("deadConsumer01 接收到消息:" + message + "并拒绝签收该消息");
//            channel.basicNack(deliveryTag,false,false);
//        }else {
//            System.out.println("deadConsumer01 接收到消息"+message);
//            channel.basicAck(deliveryTag,false);
//        }
//    }
//
//    @RabbitListener(ackMode = "MANUAL",bindings ={
//            @QueueBinding(value = @Queue(value = RabbitMqConfig.DEAD_QUEUE,durable = "true"),
//                    exchange =@Exchange(value = RabbitMqConfig.DEAD_EXCHANGE),
//                    key = "lisi")})
//    public void deadConsumer02(Message message, Channel channel) throws IOException {
//        String msg = new String(message.getBody());
//        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
//        System.out.println("死信交换机发来的消息:"+msg);
//    }
//
//    @RabbitListener(queues = RabbitMqConfig.DELAY_QUEUE)
//    public void deadConsumer03(Message message){
//        log.info("当前时间{},收到延时队列的消息222:{}",new Date(),new String(message.getBody()));
//    }
//
//
//}
